/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.restaurant.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;

/**
 *
 * @author Dexter
 */
@Entity
@Table(name = "Tables")
@NamedQueries({
    @NamedQuery(name = "Tables.findAll", query = "SELECT t FROM Tables t"),
    @NamedQuery(name = "Tables.findByTableId", query = "SELECT t FROM Tables t WHERE t.tableId = :tableId"),
    @NamedQuery(name = "Tables.findByName", query = "SELECT t FROM Tables t WHERE t.name = :name"),
    @NamedQuery(name = "Tables.findByDescription", query = "SELECT t FROM Tables t WHERE t.description = :description"),
    @NamedQuery(name = "Tables.findByNumberOfPlaces", query = "SELECT t FROM Tables t WHERE t.numberOfPlaces = :numberOfPlaces")})
public class Tables implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "TableId")
    private Long tableId;
    @Size(max = 120)
    @Column(name = "Name")
    private String name;
    @Size(max = 1000)
    @Column(name = "Description")
    private String description;
    @Column(name = "NumberOfPlaces")
    private Integer numberOfPlaces;
    @OneToMany(mappedBy = "tableId", fetch = FetchType.LAZY)
    private List<TablesInReservations> tablesInReservationsList;

    public Tables() {
    }

    public Tables(Long tableId) {
        this.tableId = tableId;
    }

    public Long getTableId() {
        return tableId;
    }

    public void setTableId(Long tableId) {
        this.tableId = tableId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getNumberOfPlaces() {
        return numberOfPlaces;
    }

    public void setNumberOfPlaces(Integer numberOfPlaces) {
        this.numberOfPlaces = numberOfPlaces;
    }

    public List<TablesInReservations> getTablesInReservationsList() {
        return tablesInReservationsList;
    }

    public void setTablesInReservationsList(List<TablesInReservations> tablesInReservationsList) {
        this.tablesInReservationsList = tablesInReservationsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tableId != null ? tableId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tables)) {
            return false;
        }
        Tables other = (Tables) object;
        if ((this.tableId == null && other.tableId != null) || (this.tableId != null && !this.tableId.equals(other.tableId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.restaurant.entities.Tables[ tableId=" + tableId + " ]";
    }
    
}
